import numpy as np
a = np.array([3, 4])

norm_a = np.linalg.norm(a)
print(norm_a)  # 5

unit_a = a / norm_a
print(unit_a)  # [0.6, 0.8]

print(norm_a * unit_a)

print('========')

x1, x2 = 3, 4
# 极径 5
r = np.sqrt(x1**2 + x2**2)
print(r)
# 极角
theta = np.arctan2(x2, x1)
print(theta)  # 0.927
print(np.rad2deg(theta))  # 53.130
# 转换为直角坐标系
x1_ = r * np.cos(theta)
x2_ = r * np.sin(theta)
print(x1_, x2_)  # 3.0  3.99999


